#include "Image.h"
#include <cstdio>
/* static */ bool Image::Saver::Save(const Image *pImage, const char *szFileName)
{
	const U8 *pData = pImage->GetData();
	U32 nSize = pImage->GetWidth() * pImage->GetHeight();
	FILE *f;
	f = fopen(szFileName, "wb");
	if (f == NULL) return false;
	fprintf(f,"P5\n%d %d\n255\n",pImage->GetWidth(),pImage->GetHeight());	
	while(nSize--) fputc(*pData++,f);	
	fclose(f);
	return true;
}
